from selenium import webdriver
from time import sleep, time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome()
driver.maximize_window()
driver.maximize_window()
driver.get('http://106.52.182.140/fanwe/')
driver.implicitly_wait(5)
driver.find_element(By.ID,'login-email-address').send_keys('cxy2104')
driver.find_element(By.ID,'login-password').send_keys('cxy123456')
driver.find_element(By.ID,'Iajax-login-submit').click()
driver.find_element(By.CLASS_NAME,'dialog-cancel').click()
#等待
sleep(3)
driver.find_element(By.XPATH,'//*[@class="user_info_d"]/a[2]').click()   #打开个人资料
driver.find_element(By.XPATH,'//*[@id="edit-account"]').click()   #点击编辑资料
driver.find_element(By.XPATH,'//*[@id="settings-university"]').clear()   #清除毕业院校原来的信息
driver.find_element(By.XPATH,'//*[@id="settings-university"]').send_keys('大学')   #填写大学
#点击取消

#页面下拉框：导入select 包 from selenium.webdriver.support.ui import Select
#修改select的属性将隐藏修改为可见
js='document.querySelectorAll("select")[1].style.display="block";'
driver.execute_script(js)

#修改省份
xl_en="/html/body/div[2]/div[3]/div[2]/form/table/tbody/tr[2]/td[2]/div[15]/div[8]/span/select[1]"
s_el=driver.find_element(By.XPATH,xl_en)
s=Select(s_el)
s.select_by_index(12)
# time.sleep(2)

#修改select的属性将隐藏修改为可见
js_2='document.querySelectorAll("select")[2].style.display="block";'
driver.execute_script(js_2)
#修改城市
el1="/html/body/div[2]/div[3]/div[2]/form/table/tbody/tr[2]/td[2]/div[15]/div[8]/span/select[2]"
s_el2=driver.find_element(By.XPATH,el1)
s=Select(s_el2)
s.select_by_index(2)
# time.sleep(2)
driver.find_element(By.XPATH,'//*[@id="settings-submit"]').click()   #点击保存
#driver.back()   #返回首页